from django.db import models
from django.contrib.auth.models import User #导入用户模型


class BlogType(models.Model):
    type_name = models.CharField(max_length=30)

    def __str__(self):
        return self.type_name

class Blog(models.Model):
    title = models.CharField(max_length=60,default="title")
    blog_type = models.ForeignKey(BlogType , on_delete=models.DO_NOTHING)
    content = models.TextField()
    author = models.ForeignKey(User , on_delete=models.DO_NOTHING)
    create_time = models.DateTimeField(auto_now_add=True)
    last_update_time = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return "<Blog: %s>" % self.title

